package swordoffer.offer62;

public class JosephusProblem {
    public int lastRemaining(int n, int m) {
        int live = getLive(n, m);
        return live;
    }

    public int getLive(int n, int m) {
        if (n == 1) {
            return 0;
        }
        int res = (getLive(n - 1, m) + m)% n;
        return res;
    }
}
